package name;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Severce {
    public static void main(String[] args) throws Exception {
        System.out.println("服务端开始启动");
        //1.创建服务端的接口Sever Socket（）
         ServerSocket serverSocket = new ServerSocket(1314);

         //2.使用server Socket对象，调用accept方法来请求客户端连接

         //3.从serverSocket.accept()通信管道中得到一个字节输入流

        //4.将字节数入流包装成数据字节输入流

        //开始接受客户端信息
        while (true) {
            try {
                Socket socket=serverSocket.accept();
                System.out.println("有人上线了："+socket.getRemoteSocketAddress());
                new SeverceTHread(socket).start();

            } catch (IOException e) {
                System.out.println("客户端终止");
               serverSocket.close();
                break;
            }

        }
        //获取客户端的ip地址



    }
}
